/**
 * 
 */
package ch.iec.tc57._2011.meterreadings.clientsample.beans;

import java.io.Serializable;
import java.util.ArrayList;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

import com.primestone.cim.util.CollectionUtil;

/**
 * @author cesar.mateus
 *
 */
@XmlAccessorType(XmlAccessType.FIELD) 
@XmlRootElement
public class ListResult implements Serializable {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7658742768220182259L;
	private ArrayList<Pair> pairs;
	private String summary;

	/**
	 * 
	 */
	public ListResult() {}
	
	/**
	 * 
	 * @param pair
	 */
	public ListResult(Pair pair) {
		super();
		this.pairs = new ArrayList<Pair>();
		this.pairs.add(pair);
	}
	
	/**
	 * @param pairs
	 */
	public ListResult(ArrayList<Pair> pairs) {
		super();
		this.pairs = pairs;
	}
	
	/**
	 * 
	 * @param pair
	 */
	public void add(Pair pair) {
		if (!CollectionUtil.safe(this.pairs)) {
			this.pairs = new ArrayList<Pair>();
		} 
		this.pairs.add(pair);
	}

	/**
	 * @return the pairs
	 */
	public ArrayList<Pair> getPairs() {
		return this.pairs;
	}
	
	/**
	 * 
	 * @return
	 */
	public String getPairsInfo() {
		StringBuilder info = new StringBuilder();
		if (CollectionUtil.safe(this.pairs)) {
			for (Pair pair : this.pairs) {
				info.append(pair).append(",").append(" ");
			}	
		}
		return info.toString();
	}

	/**
	 * @param pairs the pairs to set
	 */
	public void setPairs(ArrayList<Pair> pairs) {
		this.pairs = pairs;
	}

	/**
	 * @return the summary
	 */
	public String getSummary() {
		return this.summary;
	}

	/**
	 * @param summary the summary to set
	 */
	public void setSummary(String summary) {
		this.summary = summary;
	}
	
}
